import { pget, ppostJson, post } from '@/utils/req'
import { modalApi } from '@/utils/modalReq'

// 付款申请分页
export function getTableList(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/page`,
		data,
	)
}

// 付款申请不分页
export function getTablePage(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/list`,
		data,
	)
}

// 发票核销分页
export function getWriteTableList(data: any) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-invoice/invoice/page`,
		data,
	)
}

// 新增付款申请
export function addPayment(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/save`,
		data,
	)
}
/** 付款申请保存 */
export function paymentSaveTemporary(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/saveTemporary`,
		data,
	);
}

// 修改付款申请
export function editPayment(id: string, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/update/${id}`,
		data,
	)
}

// 删除付款申请
export function deletePayment(data: { ids: string }) {
	return post(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/remove`,
		data,
	)
}

// 查看付款申请
export function viewPayment(id: string) {
	return pget(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/detail/${id}`,
	)
}

/** 保存付款申请导入数据 */
export function applypayImport(query?: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/import/${query.batch}`,
	)
}
/** 保存发票导入数据 */
export function invoiceImport(query?: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-invoice/invoice/import/${query.id}/${query.batch}`,
	)
}

// 获取供应商银行信息
export function getSupplierBankData(query: any) {
	return pget(
		`${modalApi.supplier}/supplier/currency/getSupplierBankData`,
		query,
	)
}

// 工作流接口

/** 流程新增 */
export function paymentProcessAdd(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/submitFlow`,
		data,
	)
}
// 付款申请审核
export function paymentAuditFlow(data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/auditFlow`,
		data,
	)
}
// 作废付款申请重新发起审核
export function paymentRelaunchFlow(id: any, data: any) {
	return ppostJson(
		`${modalApi.purchase}/shopec-purchase-applypay/applypay/relaunchFlow/${id}`,
		data,
	)
}
